package com.tacuati.content;

import org.apache.commons.io.FilenameUtils;

public enum Format {
	MOBI, PDF, AZW, APNX, MBP, PDR, EA, PHL, PRC, TAN, UNKNOWN;

	public static Format getFormat(String archivo) {
		String extension = FilenameUtils.getExtension(archivo).toUpperCase();
		if (extension.equals("MOBI")) {
			return MOBI;
		} else if (extension.equals("PDF")) {
			return PDF;
		} else if (extension.equals("AZW")) {
			return AZW;
		} else if (extension.equals("APNX")) {
			return APNX;
		} else if (extension.equals("MBP")) {
			return MBP;
		} else if (extension.equals("PDR")) {
			return PDR;
		} else if (extension.equals("EA")) {
			return EA;
		} else if (extension.equals("PHL")) {
			return PHL;
		} else if (extension.equals("PRC")) {
			return PRC;
		} else if (extension.equals("TAN")) {
			return TAN;
		} else {
			return UNKNOWN;
		}
	}

	public boolean isValidItem() {
		return !(this.ordinal() == APNX.ordinal() || this.ordinal() == MBP.ordinal() || this.ordinal() == PDR.ordinal() || this.ordinal() == EA.ordinal() || this.ordinal() == PHL.ordinal() || this
				.ordinal() == TAN.ordinal());
	}
}